package ManageGameHServer.classFile;

import ManageGameHServer.conf.Setup;

import java.io.File;
import java.io.FileWriter;

/**
 * Created by lt on 2016/9/24.
 */
public class Log {
    public static final void requestLog (String con){
        try {
            String Home = Setup.homeUrl;
            String logUrl = Setup.logErrorFile;
            File file = new File(Home + logUrl);
            if (!file.exists()) {
                file.createNewFile();
            }
            FileWriter fileLogWriter = new FileWriter(Home + logUrl, true);
            fileLogWriter.write(con + "\n");
            fileLogWriter.close();
        }catch (Exception e){
            //System.out.println("LogClass:"+e.getMessage());
        }
    }
    public static final void errorLog(String con) {
        try {
            String Home = Setup.homeUrl;
            String logUrl = Setup.logErrorFile;
            File file = new File(Home + logUrl);
            if (!file.exists()) {
                file.createNewFile();
            }
            FileWriter fileLogWriter = new FileWriter(Home + logUrl, true);
            fileLogWriter.write(con + "\n");
            fileLogWriter.close();
        }catch (Exception e){
            //System.out.println("LogClass:"+e.getMessage());
        }
    }
    public static final  void  errorLog( StackTraceElement[] conArray){
        try {
            String Home = Setup.homeUrl;
            String logUrl = Setup.logErrorFile;
            File file = new File(Home + logUrl);
            if (!file.exists()) {
                file.createNewFile();
            }
            FileWriter fileLogWriter = new FileWriter(Home + logUrl, true);
            for (int i=0;i<conArray.length;i++) {
                fileLogWriter.write(conArray[i] + "\n");
            }
            fileLogWriter.close();
        }catch (Exception e){
            //System.out.println("LogClass:"+e.getMessage());
        }
    }
}
